package com.oraro.paygatewaybiz.channel.wxpay.tradetype.jsapi;

import com.oraro.common.result.Result;
import com.oraro.paygatewaybiz.channel.wxpay.interfaces.WXPayService;
import com.oraro.paygatewaybiz.channel.wxpay.serviceImpl.AbstractWXBaseService;
import com.oraro.paygatewaybiz.constant.Constants;
import com.oraro.paygatewaybiz.module.entity.ChannelEntity;
import com.oraro.paygatewaybiz.module.entity.OrderEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author: jianghuiyong
 * @Date: 2018/11/28 14:44
 * @Version 1.0
 */
@Slf4j
@Service
public class WXJsapiPayService extends AbstractWXBaseService implements WXPayService {

    @Override
    public String type() {
        return Constants.tradeType.WXJSAPI.getType();
    }

    @Override
    public Result payOrder(OrderEntity orderEntity, ChannelEntity channelEntity) {
        Map<String, String> map = getWXRequestData(orderEntity);
        //trade_type=JSAPI，openid参数必传
        map.put("openid", orderEntity.getOpenid());
        return unifiedOrder(map, channelEntity);
    }

}
